define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_orderlist(result) {
			if(false) {
				result = '{"success": true,"msg": "","result":' +
					'{"store_name": "世达","order_count": 100,"order_money": 1000,"order": [' +
					'{"id": "123456789","buyer_name": "买家1","count": 10,"total_amount": 100},' +
					'{"id": "223456789","buyer_name": "买家2","count": 90,"total_amount": 900}]},' +
					'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//返回信息
		return {
			//代理商订单一览
			myagent_list: function(params, callback, calldone) {
				//				//post请求
				Http.post({
						method: 'member.agenter.orderlist',
						picSize: 'CS',
						pagelimit: 10,
						nPage: params.nPage,
						store_id: params.store_id,
						order_id: params.order_id,
						goods_name: params.goods_name,
						time: params.time,
						ordertype: params.ordertype,
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_orderlist(result).result);

					},
					function(err) {
						console.log(1);
						//请求完成
						if(calldone)
						calldone();
					},
					function() {
						if(calldone)
						calldone();
					}
				);
			},
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Myagent_order", factory);
});